package com.example.todaynews.util;

import android.app.Activity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wj on 2016/8/18.
 */
public class ActivityCollector {
    public static List<Activity> list = new ArrayList<Activity>();

    public static void addActivity(Activity activity) {
        list.add(activity);
    }

    public static void removeActivity(Activity activity) {
        list.remove(activity);
    }

    public static void finishAll() {

        try {
            for (Activity activity : list) {
                if (activity != null) {
                    activity.finish();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.exit(0);
        }
    }
}
